Xcode Treasures by Chris Adamson

Xcode Treasures by Chris Adamson

Author:Chris Adamson
Language: eng
Format: epub
Tags: Pragmatic Bookshelf
Publisher: Pragmatic Bookshelf


Breakpoint Actions

The bottom two items in the breakpoint editor pop-over are the Action and Options sections. There’s only one option: automatically continuing after hitting the breakpoint. That seems pointless, right? Why hit a breakpoint only to then continue?

The reason to continue is that the “Add Action” button lets you add actions, and it’s often enough to perform that action and continue, without stopping to investigate anything.

The simplest thing you can add is a logging action. Once you click, “Add Action”, the UI expands to offer a pop-up menu of action types, and various buttons and text fields to customize the action. The simplest to understand is the Log Message action. It can log a string to the console or send it to the Mac’s speech synthesizer to be spoken aloud. It also allows you to use @expression@ syntax to evaluate expressions in the currently active language and insert them into the log string.

The following figure shows a breakpoint on the isPrime = false line, logging a reason for ruling out candidate as a prime number, with the log string @candidate@ is not prime (divisible by @divisor@):



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.